/**基本物件派生类:图像
 * 实现图片纹理的加载和生成
 * @author: zzy
 * @data: 2010 4 12
 */
package cn.edu.dlut.WingGame.Object;

import cn.edu.dlut.WingGame.BaseType.WingColor;
import cn.edu.dlut.WingGame.Graphic.GLTexture;

public class WingImage extends WingObject {
	protected float x = 0;
	protected float y = 0;
	protected float src_x = 0;
	protected float src_y = 0;
	protected float width;
	protected float height;
	protected float src_width;
	protected float src_height;
	protected float rotation = 0;
	protected float alpha = 1;

	private boolean flag1 = false;
	private boolean flag2 = false;
	private boolean flag3 = false;

	// private int ResourceID;
	// private String Path;
	// private WingColor keycolor;

	private GLTexture ObjectTexture = new GLTexture();

	public WingImage() {
	}

	public WingImage(int ResourceID) {
		ObjectTexture.creatTexture(ResourceID);
	}

	public WingImage(String Path) {
		ObjectTexture.creatTexture(Path);
	}

	public WingImage(int ResourceID, WingColor keycolor) {
		ObjectTexture.creatTexture(ResourceID, keycolor);
	}

	public WingImage(String Path, WingColor keycolor) {
		ObjectTexture.creatTexture(Path, keycolor);
	}

	// public void setKeycolor(WingColor keycolor){
	// this.keycolor = keycolor;
	// }

	public void setPos(float x, float y) {
		this.x = x; // 状态1
		this.y = y;
	}

	public void setSize(float width, float height) {
		this.width = width;
		this.height = height;
		if (flag1 == false) {
			flag1 = true; // 状态3
			flag2 = false;
			flag3 = true;
		} else {
			flag1 = false; // 状态4
			flag2 = true;
		}
	}

	public void setRota_Alpha(float rotation, float alpha) {
		this.rotation = rotation;
		this.alpha = alpha;
		if (flag1 == false) {
			flag1 = true; // 状态3
			flag2 = false;
			flag3 = false;
		} else {
			flag1 = false; // 状态4
			flag2 = true;
		}

	}

	public void setSrc_pos(float src_x, float src_y) {
		this.src_x = src_x;
		this.src_y = src_y;
		flag1 = true; // 状态5
		flag2 = true;
	}

	public void setSrc_size(float src_width, float src_height) {
		this.src_width = src_width;
		this.src_height = src_height;
		flag1 = true; // 状态5
		flag2 = true;
	}

	@Override
	public void render() {
		// TODO Auto-generated method stub
		if (flag1 == false && flag2 == false) // 状态1
			ObjectTexture.draw(x, y);
		else if (flag1 == true && flag2 == false && flag3 == true) // 状态2
			ObjectTexture.draw(x, y, width, height);
		else if (flag1 == true && flag2 == false && flag3 == false) // 状态3
			ObjectTexture.drawEx(x, y, rotation, alpha);
		else if (flag1 == false && flag2 == true) // 状态4
			ObjectTexture.drawEx(x, y, width, height, rotation, alpha);
		else if (flag1 == true && flag2 == true) // 状态5
			ObjectTexture.drawEx(x, y, width, height, src_x, src_y, src_width,
					src_height, rotation, alpha);
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		// x += 5;
		// y += 5;
	}

}
